﻿using System.Net.Http.Headers;

namespace iOSClub.App.Share.Serves;

public abstract class IServer : IDisposable
{
    private string _jwt = "";
    
    // protected const string _url = "http://localhost:5102/api";
    protected const string _url = "https://www.xauat.site/api";

    protected string Jwt
    {
        get => _jwt;
        set
        {
            _jwt = value;
            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _jwt);
        }
    }

    protected readonly HttpClient httpClient = new();

    void IDisposable.Dispose()
    {
        httpClient.Dispose();
        GC.SuppressFinalize(this);
    }

    protected IServer()
    {
        Jwt = "";
    }

    protected IServer(string jwt) => Jwt = jwt;

    protected IServer(IServer server)
    {
        Jwt = server.Jwt;
    }
}